package org.deri.feather.sample;

import java.util.Vector;

import org.deri.feather.common.ConfigurationManager;
import org.deri.feather.common.Entity;
import org.deri.feather.common.Triple;
import org.deri.feather.loader.NTLoader;
import org.deri.feather.search.Search;

public class DBpediaTest {

	public DBpediaTest() {

	}
	
	public void load() {

		NTLoader loader = new NTLoader();
		loader.setUp("http://dbpedia.org");
		loader.load("data/dbpedia_sample.nt");
	}
	
	public void query() {
		
		Search search = new Search();
		search.setUp();
		
		Vector<Triple> triples = new Vector<Triple>();
		triples = search.queryByTriplePattern("", "", "Michael Jackson");
		for(Triple triple : triples)
			System.out.println(": " + triple.toString());
		
		if (ConfigurationManager.getInstance().enableKeywordIndex() || ConfigurationManager.getInstance().enableLiteralIndex()) {
			Vector<Entity> entities = new Vector<Entity>();
			entities = search.valueSearch("An agronomist measures and records corn growth and other processes.", "http://dbpedia.org"); //\TODO implement
			for(Entity entity : entities)
				System.out.println(">> " + entity.uri);
		}
	}
	
	public static void main(String[] args) {

		DBpediaTest dbpediaTest = new DBpediaTest();
		//dbpediaTest.load();
		dbpediaTest.query();
		
	}

}
